<?
//---------------------------------------------
// AskTwitter - Twitter based realtime QA system
// Author: Seokchan (Channy) Yun
// License: BSD License
// Version: 0.1
//----------------------------------------------

	include "asklift.inc";

	// Ask action from web
	if($_GET[action]=='ask' AND $_POST[q]) {
		_db_insert("INSERT messages VALUES('',".rand().",'".addslashes($_POST[q])."','webquestion','http://www.liftconference.com/files/images/nophoto.gif','".$_POST[to]."','aa')");
		Header("Location: index.php");
		exit;

	// Voting action from web
	} else if($_GET[action]=='vote' AND $_GET[msgid]) {
		$name = $_GET[msgid];
		$chk=_db_select_s("SELECT id FROM messages WHERE id=".$name." LIMIT 1");
		// check cookie and update database
		if($chk AND !$_COOKIE[$name]) {
			setcookie("$name", "yes", time()+2592000, "/", "channy.creation.net", 0);
			_db_insert("INSERT voting VALUES('',rand(),'webvoting',".$name.")");
		}
		Header("Location: index.php");
		exit;

	} else {
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ko" lang="ko" dir="ltr">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
	<title>Ask Lift 09</title>
</head>
<body style="background-image:url(http://www.liftconference.com/sites/all/themes/liftconference08/images/background_lift09_3.gif); font-family:georgia">

<table width="1000">
<tr><td align="right"><h1>Ask <img src="http://www.liftconference.com/files/lift_logo2009_RVB.gif" alt="Lift" align="absmiddle" /></h1>
</td>
<td>
<strong style="color:#ccc">Now speaking!</strong><br/>
	<img src="http://liftconference.com/files/pictures/picture-2790.jpg" width="100" align="left" hspace="20" />
	<strong>Vint Cerf</strong>(Google Inc.)<br>
	<font size="6">New frontiers</font>

</td></tr>
<tr><td width="50%">
<center><font color="red">IT'S JUST TEST.<br/><small>Now it shows only the latest <strong>four</strong> questions and takes every <strong>1 min.</strong> to update.</font>
</center>
<table width="95%" cellpadding="5">
<?
	$query=_db_select("SELECT * FROM messages ORDER BY id DESC LIMIT 4");

	while($res=_db_fetch($query)) {
		$count = 0;
		$count = _db_select_s("SELECT count(*) FROM voting WHERE voteid=".$res[id]);
		echo "<tr><td width='70' align='center'><font color='#4A968C' size='7'><strong>".$count."</strong></font><br><a href='index.php?action=vote&msgid=".$res[id]."'>vote</a></td><td><strong>".autolink($res[ttext])."</strong><br>* <font color='skyblue'>msg id</font>: <strong style='color:orange'>".$res[id]."</strong></td><td><img src='".$res[timage]."' alt='".$res[tname]."' width='48' height='48' /></td></tr>\n";
	}
?>
<tr><form method="post" action="index.php?action=ask"><td colspan='3'><strong>Q:</strong><input type="hidden" name="to" value="vint" />to Vint <input type="text" size="45" style="font-size:10pt;background-color:#eee;height:60px" name="q" value="Give a question!" onfocus="if (this.value == 'Give a question!') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Give a question!';}" /> <input type="submit" value="Ask" />
</td></form></tr>
</table>
</td>
<td width="50%" valign="middle" style="font-size:9pt;color:#666">
<h4>About Q&A system</h4>
<ul>
<li>This QA system was based on <a href="http://twitter.com/lift09" target="new">Twitter's Lift 09</a>.</li>
<li>You can ask to speakers via twitting or SMS via twitter</li>
</ul>
<h4>Send your question!</h4>
<ol>
<li>Submiting question in Ask Lift page.</li>
<li>Twitting "<font color="purple">@lift09</font> <font color="blue">vint::</font><i>Your question</i>". on Twitter</li>
<li>Send SMS to "<font color="purple">@lift09</font> <font color="blue">vint::</font><i>Your question</i>" to <strong>+447781488126</strong></li>
</ol>

<h4>Vote favorite question!</h4>
<ol>
<li>Click "vote" in Ask Lift page.</li>
<li>Follow "lift09" and send direct only <i style='color:orange'>msg id</i> on Twitter.</li>
<li>Send SMS "d lift09 <i style='color:orange'>msg id</i>" to <strong>+447781488126</strong></li>
</ol>
<h4>If you want to SMS:</h4>
<ol>
<li>Register your phone in <a href="http://twitter.com/devices" target="new">Twitter device setting</a>.</li>
<li>Send to SMS "follow lift09"  to <strong>+447781488126</strong></li>
</ol>

<a href="http://twitter.com/lift09" target="new"><img src="http://assets0.twitter.com/images/twitter_logo_125x29.png" border="0" align="right" /></a>
</td></tr>
<tr><td colspan="2" align="center"><font size="1">Copyright(c), Channy Yun, Some rights reserved. It owes to Twitter API.</font>
</td></tr></table>
</body>
</html>
<? } ?>
